home *** CD-ROM | disk | FTP | other *** search
/ Ham Radio 2000 / Ham Radio 2000.iso / ham2000 / misc / dspice0s / moseq1.c < prev    next >
C/C++ Source or Header  |  1992-11-21  |  5KB  |  163 lines

  1. /* moseq1.f -- translated by f2c (version of 3 February 1990  3:36:42).
  2.    You must link the resulting object file with the libraries:
  3.     -lF77 -lI77 -lm -lc   (in that order)
  4. */
  5.  
  6. #include "f2c.h"
  7.  
  8. /* Common Block Declarations */
  9.  
  10. struct {
  11.     doublereal vto, beta, gamma, phi, phib, cox, xnsub, xnfs, xd, xj, xld, 
  12.         xlamda, uo, uexp, vbp, utra, vmax, xneff, xl, xw, vbi, von, vdsat,
  13.          qspof, beta0, beta1, cdrain, xqco, xqc, fnarrw, fshort;
  14.     integer lev;
  15. } mosarg_;
  16.  
  17. #define mosarg_1 mosarg_
  18.  
  19. struct {
  20.     doublereal omega, time, delta, delold[7], ag[7], vt, xni, egfet, xmu, 
  21.         sfactr;
  22.     integer mode, modedc, icalc, initf, method, iord, maxord, noncon, iterno, 
  23.         itemno, nosolv, modac, ipiv, ivmflg, ipostp, iscrch, iofile;
  24. } status_;
  25.  
  26. #define status_1 status_
  27.  
  28. struct {
  29.     doublereal twopi, xlog2, xlog10, root2, rad, boltz, charge, ctok, gmin, 
  30.         reltol, abstol, vntol, trtol, chgtol, eps0, epssil, epsox, pivtol,
  31.          pivrel;
  32. } knstnt_;
  33.  
  34. #define knstnt_1 knstnt_
  35.  
  36. /*<       subroutine moseq1(vds,vbs,vgs,gm,gds,gmbs) >*/
  37. /* Subroutine */ int moseq1_(vds, vbs, vgs, gm, gds, gmbs)
  38. doublereal *vds, *vbs, *vgs, *gm, *gds, *gmbs;
  39. {
  40.     /* Builtin functions */
  41.     double sqrt();
  42.  
  43.     /* Local variables */
  44.     static doublereal sarg, vgst, betap, arg, vbd, vgb;
  45.  
  46. /*<       implicit double precision (a-h,o-z) >*/
  47.  
  48. /*     this routine evaluates the drain current and its derivatives */
  49. /*     using the shichman-hodges model and the charges associated */
  50. /*     with the gate, channel and bulk for mosfets */
  51.  
  52. /* spice version 2g.6  sccsid=mosarg 3/15/83 */
  53. /*<       common /mosarg/ vto,beta,gamma,phi,phib,cox,xnsub,xnfs,xd,xj,xld, >*/
  54. /*<      1   xlamda,uo,uexp,vbp,utra,vmax,xneff,xl,xw,vbi,von,vdsat,qspof, >*/
  55. /*<      2   beta0,beta1,cdrain,xqco,xqc,fnarrw,fshort,lev >*/
  56. /* spice version 2g.6  sccsid=status 3/15/83 */
  57. /*<       common /status/ omega,time,delta,delold(7),ag(7),vt,xni,egfet, >*/
  58. /*<      1   xmu,sfactr,mode,modedc,icalc,initf,method,iord,maxord,noncon, >*/
  59. /*<      2   iterno,itemno,nosolv,modac,ipiv,ivmflg,ipostp,iscrch,iofile >*/
  60. /* spice version 2g.6  sccsid=knstnt 3/15/83 */
  61. /*<       common /knstnt/ twopi,xlog2,xlog10,root2,rad,boltz,charge,ctok, >*/
  62. /*<      1   gmin,reltol,abstol,vntol,trtol,chgtol,eps0,epssil,epsox, >*/
  63. /*<      2   pivtol,pivrel >*/
  64. /*<       vbd=vbs-vds >*/
  65.     vbd = *vbs - *vds;
  66. /*<       vgb=vgs-vbs >*/
  67.     vgb = *vgs - *vbs;
  68.  
  69.  
  70. /*<       if (vbs.gt.0.0d0) go to 102 >*/
  71.     if (*vbs > 0.) {
  72.     goto L102;
  73.     }
  74. /*<       sarg=dsqrt(phi-vbs) >*/
  75.     sarg = sqrt(mosarg_1.phi - *vbs);
  76. /*<       go to 104 >*/
  77.     goto L104;
  78. /*<   102 sarg=dsqrt(phi) >*/
  79. L102:
  80.     sarg = sqrt(mosarg_1.phi);
  81. /*<       sarg=sarg-vbs/(sarg+sarg) >*/
  82.     sarg -= *vbs / (sarg + sarg);
  83. /*<       sarg=dmax1(0.0d0,sarg) >*/
  84.     sarg = max(0.,sarg);
  85. /*<   104 von=vbi+gamma*sarg >*/
  86. L104:
  87.     mosarg_1.von = mosarg_1.vbi + mosarg_1.gamma * sarg;
  88. /*<       vgst=vgs-von >*/
  89.     vgst = *vgs - mosarg_1.von;
  90. /*<       vdsat=dmax1(vgst,0.0d0) >*/
  91.     mosarg_1.vdsat = max(vgst,0.);
  92. /*<       if (sarg.gt.0.0d0) go to 105 >*/
  93.     if (sarg > 0.) {
  94.     goto L105;
  95.     }
  96. /*<       arg=0.0d0 >*/
  97.     arg = 0.;
  98. /*<       go to 108 >*/
  99.     goto L108;
  100. /*<   105 arg=gamma/(sarg+sarg) >*/
  101. L105:
  102.     arg = mosarg_1.gamma / (sarg + sarg);
  103. /*<   108 if (vgst.gt.0.0d0) go to 110 >*/
  104. L108:
  105.     if (vgst > 0.) {
  106.     goto L110;
  107.     }
  108.  
  109. /*     cutoff region */
  110.  
  111. /*<       cdrain=0.0d0 >*/
  112.     mosarg_1.cdrain = 0.;
  113. /*<       gm=0.0d0 >*/
  114.     *gm = 0.;
  115. /*<       gds=0.0d0 >*/
  116.     *gds = 0.;
  117. /*<       gmbs=0.0d0 >*/
  118.     *gmbs = 0.;
  119. /*<       go to 1000 >*/
  120.     goto L1000;
  121.  
  122. /*     saturation region */
  123.  
  124. /*<   110 betap=beta*(1.0d0+xlamda*vds) >*/
  125. L110:
  126.     betap = mosarg_1.beta * (mosarg_1.xlamda * *vds + 1.);
  127. /*<       if (vgst.gt.vds) go to 120 >*/
  128.     if (vgst > *vds) {
  129.     goto L120;
  130.     }
  131. /*<       cdrain=betap*vgst*vgst*0.5d0 >*/
  132.     mosarg_1.cdrain = betap * vgst * vgst * .5;
  133. /*<       gm=betap*vgst >*/
  134.     *gm = betap * vgst;
  135. /*<       gds=xlamda*beta*vgst*vgst*0.5d0 >*/
  136.     *gds = mosarg_1.xlamda * mosarg_1.beta * vgst * vgst * .5;
  137. /*<       gmbs=gm*arg >*/
  138.     *gmbs = *gm * arg;
  139. /*<       go to 1000 >*/
  140.     goto L1000;
  141.  
  142. /*     linear region */
  143.  
  144. /*<   120 cdrain=betap*vds*(vgst-0.5d0*vds) >*/
  145. L120:
  146.     mosarg_1.cdrain = betap * *vds * (vgst - *vds * .5);
  147. /*<       gm=betap*vds >*/
  148.     *gm = betap * *vds;
  149. /*<       gds=betap*(vgst-vds)+xlamda*beta*vds*(vgst-0.5d0*vds) >*/
  150.     *gds = betap * (vgst - *vds) + mosarg_1.xlamda * mosarg_1.beta * *vds * (
  151.         vgst - *vds * .5);
  152. /*<       gmbs=gm*arg >*/
  153.     *gmbs = *gm * arg;
  154.  
  155. /*     finished */
  156.  
  157. /*<  1000 return >*/
  158. L1000:
  159.     return 0;
  160. /*<       end >*/
  161. } /* moseq1_ */
  162.  
  163.